package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFormat;

	public class MenuBox extends Sprite
	{
		[Embed(source="../res/menuBox.png")]
        public var ImageBox:Class;
		public var imageBox:Bitmap;
		public var wholeBox:Bitmap;
		public var title:TextField = new TextField();
		public var textSize:int = 24;
		public var onClick:Function;
		public var parentMenu:Menu;
		
		/**
		 * Object : MenuBox
		 * Parameters : title:String the string that should be used as title for the button.
		 */
		public function MenuBox(menu:Menu, title:String, onClick:Function, x:int, y:int){
			this.parentMenu = menu;
			
			var myFormat:TextFormat = new TextFormat();
			myFormat.size = this.textSize;
			this.title.defaultTextFormat = myFormat;
			
			this.title.text = title;
			this.title.autoSize = "left";
			
			this.onClick = onClick;
			
			this.imageBox = new ImageBox();
			
			this.x = x;
			this.y = y;
			
			this.addChild(this.title);
			
		}
		
		public function center(w:int, h:int):void{
			centerVertically(w);
			centerHorizontally(h);
		}
		
		public function centerVertically(w:int):void{
			this.x = (w - this.width) / 2;
		}
		
		public function centerHorizontally(h:int):void{
			this.y = (h - this.height) / 2;
		}
	}	
}